<?php

namespace App\Admin\Extensions\Tools;

use Encore\Admin\Grid\Tools\BatchAction;

class getInjectData extends BatchAction
{
    protected $injectType;

    public function __construct($injectType)
    {
        $this->injectType = $injectType;
    }

    public function script()
    {
        return <<<EOT
        $('{$this->getElementClass()}').on('click', function() {
            var ids = selectedRows();
            if(ids =='' || ids == null || typeof(ids)=='undefined'){
              layer.msg("请勾选数据!", {
                    icon: 5
              });
              return false;
            }
            
            window.location.href = '/admin/entity/assets/assets/inject_data/view?ids='+selectedRows()+'&injectType={$this->injectType}';
            
        });

EOT;

    }
}